home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1996-05-01 | 13.9 KB | 330 lines | [ TEXT/MPS ]
{ File: StringCompare.p Contains: Public interfaces for String Comparison and related operations Version: Technology: System 7.0 through System 8 Release: Universal Interfaces 3.0d3 on Copland DR1 Copyright: © 1984-1996 by Apple Computer, Inc. All rights reserved. Bugs?: If you find a problem with this file, send the file and version information (from above) and the problem description to: Internet: apple.bugs@applelink.apple.com AppleLink: APPLE.BUGS } {$IFC UNDEFINED UsingIncludes} {$SETC UsingIncludes := 0} {$ENDC} {$IFC NOT UsingIncludes} UNIT StringCompare; INTERFACE {$ENDC} {$IFC UNDEFINED __STRINGCOMPARE__} {$SETC __STRINGCOMPARE__ := 1} {$I+} {$SETC StringCompareIncludes := UsingIncludes} {$SETC UsingIncludes := 1} {$IFC UNDEFINED __TYPES__} {$I Types.p} {$ENDC} {$IFC UNDEFINED __TEXTCOMMON__} {$I TextCommon.p} {$ENDC} {$IFC UNDEFINED __SCRIPT__} {$I Script.p} {$ENDC} {$IFC UNDEFINED __TEXTOBJECTS__} {$I TextObjects.p} {$ENDC} {$IFC UNDEFINED __LOCALEOBJECTS__} {$I LocaleObjects.p} {$ENDC} {$IFC UNDEFINED __TEXTPARSER__} {$I TextParser.p} {$ENDC} {$PUSH} {$ALIGN MAC68K} {$LibExport+} { Here are the current System 7 routine names and the translations to the older forms. Please use the newer forms in all new code and migrate the older names out of existing code as maintenance permits. NEW NAME OLD NAME OBSOLETE FORM (no handle) CompareString (Str255) IUCompPString (hp only) IUCompString (hp only) CompareText (ptr/len) IUMagPString IUMagString IdenticalString (Str255) IUEqualPString (hp only) IUEqualString (hp only) IdenticalText (ptr/len) IUMagIDPString IUMagIDString LanguageOrder IULangOrder ScriptOrder IUScriptOrder StringOrder (Str255) IUStringOrder (hp only) TextOrder (ptr/len) IUTextOrder RelString CmpString (a only) EqualString (hp only) ReplaceText } {$IFC FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE } CONST { Special language code values for Language Order } systemCurLang = -2; { current (itlbLang) lang for system script } systemDefLang = -3; { default (table) lang for system script } currentCurLang = -4; { current (itlbLang) lang for current script } currentDefLang = -5; { default lang for current script } scriptCurLang = -6; { current (itlbLang) lang for specified script } scriptDefLang = -7; { default language for a specified script } { obsolete names } iuSystemCurLang = -2; iuSystemDefLang = -3; iuCurrentCurLang = -4; iuCurrentDefLang = -5; iuScriptCurLang = -6; iuScriptDefLang = -7; {$ENDC} { FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE } {$IFC FOR_SYSTEM8_PREEMPTIVE } TYPE CollationRef = ^LONGINT; ConstBytePtr = ^UInt8; { Collation object key names } { Attribute names and values for CreateCollationRef } CollateUsageAttributeValue = FourCharCode; CONST kCollateUsageDictionary = 'dict'; kCollateUsagePhoneDirectory = 'phon'; TYPE CollateIdeoOrderAttributeValue = FourCharCode; CONST kCollateIdeoOrderRadicalStroke = 'rdst'; kCollateIdeoOrderStrokeRadical = 'strd'; { Override types and enums } TYPE CollationSetPtr = ^CollationSet; CollationSet = RECORD charGroup: SInt8; charClass: SInt8; charSubclassMask: CharacterSubclassMask; END; CollateSetOptions = OptionBits; CONST kCollateMakeIgnorableBit = 0; kCollateSkipPreprocessingBit = 1; kCollateIgnoreAnnotationsBit = 2; kCollateMakeIgnorableMask = $01; kCollateSkipPreprocessingMask = $02; kCollateIgnoreAnnotationsMask = $04; TYPE CollationSetOptionSpecPtr = ^CollationSetOptionSpec; CollationSetOptionSpec = RECORD charGroup: SInt8; charClass: SInt8; charSubclassMask: CharacterSubclassMask; options: CollateSetOptions; END; CollateNumberOptions = OptionBits; CONST kCollateNumbersByValueBits = 0; kCollateAllowThousandsSepBits = 2; kCollateMoreThousandsSepBit = 4; kCollateAllowIdeoNumbersBit = 5; kCollateNumbersByValueMask = $03; kCollateAllowThousandsSepMask = $0C; kCollateMoreThousandsSepMask = $10; kCollateAllowIdeoNumbersMask = $20; { values for NumbersByValue subfield } kCollateNumbersByValueUseLocale = 0; kCollateNumbersByValueNo = 1; kCollateNumbersByValueYes = 2; { values for AllowThousands subfield } kCollateAllowThousandsUseLocale = 0; kCollateAllowThousandsNo = 1; kCollateAllowThousandsYes = 2; { values for MoreThousands subfield } kCollateMoreThousandsUseLocale = 0; kCollateMoreThousandsSkipLocale = 1; { values for AllowIdeoNumbers subfield } kCollateAllowIdeoNumbersNo = 0; kCollateAllowIdeoNumbersYes = 1; TYPE CollateOptions = OptionBits; CONST kCollateStandardOptions = 0; { For determining equivalence, differences in encoding and between composed } { and decomposed characters are ignored (they are always significant for } { ordering, however). To change this use the following bits: } kCollateEncodingSensitiveBit = 8; kCollateComposeSensitiveBit = 9; { For determining equivalence, diacritics and case are normally significant. } { Use the following bits to change this. } kCollateCaseInsensitiveBit = 10; kCollateDiacriticInsensitiveBit = 11; { The following bits determine the ordering for the NoLocale functions only. } kCollateNoLocaleOrderBits = 24; kCollateEncodingSensitiveMask = $00000100; kCollateComposeSensitiveMask = $00000200; kCollateCaseInsensitiveMask = $00000400; kCollateDiacriticInsensitiveMask = $00000800; kCollateNoLocaleOrderMask = $3F000000; { values for NoLocaleOrder subfield } kCollateMacHFSUnicodeCodeOrder = 0; { HFS order for Mac encodings, code order for Unicode } { collation value for GetCollationKeyForTextString } TYPE CollationValue = UInt32; CollateResult = SInt16; {$ENDC} { FOR_SYSTEM8_PREEMPTIVE } {$IFC FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE } { The following functions are old names, but are required for System 7 PowerPC builds becuase InterfaceLib exports these names, instead of the new ones. } FUNCTION IUMagPString(aPtr: UNIV Ptr; bPtr: UNIV Ptr; aLen: INTEGER; bLen: INTEGER; itl2Handle: Handle): INTEGER; {$IFC NOT GENERATINGCFM} INLINE $3F3C, $001A, $A9ED; {$ENDC} FUNCTION IUMagIDPString(aPtr: UNIV Ptr; bPtr: UNIV Ptr; aLen: INTEGER; bLen: INTEGER; itl2Handle: Handle): INTEGER; {$IFC NOT GENERATINGCFM} INLINE $3F3C, $001C, $A9ED; {$ENDC} FUNCTION IUTextOrder(aPtr: UNIV Ptr; bPtr: UNIV Ptr; aLen: INTEGER; bLen: INTEGER; aScript: ScriptCode; bScript: ScriptCode; aLang: LangCode; bLang: LangCode): INTEGER; {$IFC NOT GENERATINGCFM} INLINE $3F3C, $0022, $A9ED; {$ENDC} FUNCTION IUScriptOrder(script1: ScriptCode; script2: ScriptCode): INTEGER; {$IFC NOT GENERATINGCFM} INLINE $3F3C, $001E, $A9ED; {$ENDC} FUNCTION IULangOrder(language1: LangCode; language2: LangCode): INTEGER; {$IFC NOT GENERATINGCFM} INLINE $3F3C, $0020, $A9ED; {$ENDC} FUNCTION IUCompPString(aStr: Str255; bStr: Str255; itl2Handle: Handle): INTEGER; FUNCTION IUEqualPString(aStr: Str255; bStr: Str255; itl2Handle: Handle): INTEGER; FUNCTION IUStringOrder(aStr: Str255; bStr: Str255; aScript: ScriptCode; bScript: ScriptCode; aLang: LangCode; bLang: LangCode): INTEGER; { The following are new names which are not exported by System 7 InterfaceLib for PowerPC. For C the new names are mapped to the old names using #define. } FUNCTION CompareText(aPtr: UNIV Ptr; bPtr: UNIV Ptr; aLen: INTEGER; bLen: INTEGER; itl2Handle: Handle): INTEGER; {$IFC NOT GENERATINGCFM} INLINE $3F3C, $001A, $A9ED; {$ENDC} FUNCTION IdenticalText(aPtr: UNIV Ptr; bPtr: UNIV Ptr; aLen: INTEGER; bLen: INTEGER; itl2Handle: Handle): INTEGER; {$IFC NOT GENERATINGCFM} INLINE $3F3C, $001C, $A9ED; {$ENDC} FUNCTION TextOrder(aPtr: UNIV Ptr; bPtr: UNIV Ptr; aLen: INTEGER; bLen: INTEGER; aScript: ScriptCode; bScript: ScriptCode; aLang: LangCode; bLang: LangCode): INTEGER; {$IFC NOT GENERATINGCFM} INLINE $3F3C, $0022, $A9ED; {$ENDC} FUNCTION LanguageOrder(language1: LangCode; language2: LangCode): INTEGER; {$IFC NOT GENERATINGCFM} INLINE $3F3C, $0020, $A9ED; {$ENDC} FUNCTION CompareString(aStr: Str255; bStr: Str255; itl2Handle: Handle): INTEGER; FUNCTION IdenticalString(aStr: Str255; bStr: Str255; itl2Handle: Handle): INTEGER; FUNCTION StringOrder(aStr: Str255; bStr: Str255; aScript: ScriptCode; bScript: ScriptCode; aLang: LangCode; bLang: LangCode): INTEGER; { The following functions are new names that are exported by InterfaceLib and work on both 68k and System 7 PowerPC. } FUNCTION ScriptOrder(script1: ScriptCode; script2: ScriptCode): INTEGER; {$IFC NOT GENERATINGCFM} INLINE $3F3C, $001E, $A9ED; {$ENDC} FUNCTION ReplaceText(baseText: Handle; substitutionText: Handle; VAR key: Str15): INTEGER; {$IFC NOT GENERATINGCFM} INLINE $2F3C, $820C, $FFDC, $A8B5; {$ENDC} {$ENDC} { FOR_SYSTEM7_AND_SYSTEM8_COOPERATIVE } {$IFC FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED } FUNCTION IUMagString(aPtr: UNIV Ptr; bPtr: UNIV Ptr; aLen: INTEGER; bLen: INTEGER): INTEGER; {$IFC NOT GENERATINGCFM} INLINE $3F3C, $000A, $A9ED; {$ENDC} FUNCTION IUMagIDString(aPtr: UNIV Ptr; bPtr: UNIV Ptr; aLen: INTEGER; bLen: INTEGER): INTEGER; {$IFC NOT GENERATINGCFM} INLINE $3F3C, $000C, $A9ED; {$ENDC} FUNCTION IUCompString(aStr: Str255; bStr: Str255): INTEGER; FUNCTION IUEqualString(aStr: Str255; bStr: Str255): INTEGER; {$ENDC} { FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED } {$IFC FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE } FUNCTION RelString(str1: Str255; str2: Str255; caseSensitive: BOOLEAN; diacSensitive: BOOLEAN): INTEGER; FUNCTION EqualString(str1: Str255; str2: Str255; caseSensitive: BOOLEAN; diacSensitive: BOOLEAN): BOOLEAN; {$ENDC} { FOR_SYSTEM7_AND_SYSTEM8_PREEMPTIVE } {$IFC FOR_SYSTEM8_PREEMPTIVE } FUNCTION CreateCollationRef(collMasterObject: LocaleObjectRef; locale: LocaleRef; countPairs: ItemCount; {CONST}VAR pairs: NameValuePair; VAR newCollationRef: CollationRef): OSStatus; C; FUNCTION ChangeCollationRef(collationRef: CollationRef; collMasterObject: LocaleObjectRef; locale: LocaleRef; countPairs: ItemCount; {CONST}VAR pairs: NameValuePair): OSStatus; C; FUNCTION OverrideCollationSetOrder(collationRef: CollationRef; setCount: ItemCount; VAR setList: CollationSet): OSStatus; C; FUNCTION OverrideCollationSetOptions(collationRef: CollationRef; specCount: ItemCount; VAR specList: CollationSetOptionSpec): OSStatus; C; FUNCTION OverrideCollationNumberHandling(collationRef: CollationRef; numberOptions: CollateNumberOptions; tokenCount: ItemCount; VAR tokenList: BasicToken): OSStatus; C; FUNCTION DisposeCollationRef(VAR collationRef: CollationRef): OSStatus; C; FUNCTION GetCollationKeyForTextObject(collationRef: CollationRef; textObject: ConstTextObject; options: CollateOptions; maxCollationValues: ItemCount; VAR actualCollationValues: ItemCount; VAR collationKey: CollationValue): OSStatus; C; FUNCTION GetCollationKeyForTextString(collationRef: CollationRef; textPtr: ConstBytePtr; textLength: ByteCount; textEncoding: TextEncoding; options: CollateOptions; maxCollationValues: ItemCount; VAR actualCollationValues: ItemCount; VAR collationKey: CollationValue): OSStatus; C; FUNCTION CollateTextObjects(collationRef: CollationRef; textObject1: ConstTextObject; textObject2: ConstTextObject; options: CollateOptions; VAR weakOrder: CollateResult; VAR strictOrder: CollateResult): OSStatus; C; FUNCTION CollateTextStrings(collationRef: CollationRef; textPtr1: ConstBytePtr; textLength1: ByteCount; textEncoding1: TextEncoding; textPtr2: ConstBytePtr; textLength2: ByteCount; textEncoding2: TextEncoding; options: CollateOptions; VAR weakOrder: CollateResult; VAR strictOrder: CollateResult): OSStatus; C; FUNCTION EquivalentTextObjects(collationRef: CollationRef; textObject1: ConstTextObject; textObject2: ConstTextObject; options: CollateOptions; VAR equivalent: BOOLEAN): OSStatus; C; FUNCTION EquivalentTextStrings(collationRef: CollationRef; textPtr1: ConstBytePtr; textLength1: ByteCount; textEncoding1: TextEncoding; textPtr2: ConstBytePtr; textLength2: ByteCount; textEncoding2: TextEncoding; options: CollateOptions; VAR equivalent: BOOLEAN): OSStatus; C; FUNCTION FindInTextObject(collationRef: CollationRef; baseText: ConstTextObject; baseStartIndex: TextObjectIndex; baseEndIndex: TextObjectIndex; pattern: ConstTextObject; patStartIndex: TextObjectIndex; patEndIndex: TextObjectIndex; options: CollateOptions; VAR foundStartIndex: TextObjectIndex; VAR foundEndIndex: TextObjectIndex): OSStatus; C; FUNCTION FindInTextString(collationRef: CollationRef; baseText: ConstBytePtr; baseLength: ByteCount; baseEncoding: TextEncoding; baseStartIndex: ByteOffset; baseEndIndex: ByteOffset; patText: ConstBytePtr; patLength: ByteCount; patEncoding: TextEncoding; patStartIndex: ByteOffset; patEndIndex: ByteOffset; options: CollateOptions; VAR foundStartIndex: ByteOffset; VAR foundEndIndex: ByteOffset): OSStatus; C; FUNCTION SubstituteInTextObject(collationRef: CollationRef; baseText: TextObject; startIndex: TextObjectIndex; endIndex: TextObjectIndex; substText: ConstTextObject; pattern: ConstTextObject; options: CollateOptions): OSStatus; C; { Locale-insensitive utilities for text objects For internal, user-invisible behavior thay must remain invariant across different systems } FUNCTION CollateTextObjectsNoLocale(textObject1: ConstTextObject; textObject2: ConstTextObject; options: CollateOptions; VAR weakOrder: CollateResult; VAR strictOrder: CollateResult): OSStatus; C; FUNCTION EquivalentTextObjectsNoLocale(textObject1: ConstTextObject; textObject2: ConstTextObject; options: CollateOptions; VAR equivalent: BOOLEAN): OSStatus; C; FUNCTION FindInTextObjectNoLocale(baseText: ConstTextObject; baseStartIndex: TextObjectIndex; baseEndIndex: TextObjectIndex; pattern: ConstTextObject; patStartIndex: TextObjectIndex; patEndIndex: TextObjectIndex; options: CollateOptions; VAR foundStartIndex: TextObjectIndex; VAR foundEndIndex: TextObjectIndex): OSStatus; C; {$ENDC} { FOR_SYSTEM8_PREEMPTIVE } {$ALIGN RESET} {$POP} {$SETC UsingIncludes := StringCompareIncludes} {$ENDC} {__STRINGCOMPARE__} {$IFC NOT UsingIncludes} END. {$ENDC}